package com.example.fw;

import org.openqa.selenium.By;

public class NavigationHelper extends HelperWithWebDriverBase {
	

	public NavigationHelper(ApplicationManager manager) {
		super(manager);
	}
	
	void goToGroupListPage() {
		//if (getCurrentUrl() != "http://localhost:8080/addressbookv4.1.4/group.php")	{	}
		//if (!driver.findElement(By.cssSelector("h1#header Groups")).getText().equals("Groups"))
		if (driver.findElements(By.xpath("//input[@value='New group']")).size() > 0) {
			return;
//			<form action="/addressbookv4.1.4/group.php" method="post">
//			<input type="submit" value="New group" name="new">
		}
		click(By.linkText("groups"));
	}

	void openMainPage() {
		//if (getCurrentUrl() != (baseUrl + "/addressbookv4.1.4/"))	{	}
		if (driver.findElements(By.xpath("//form[@name='MainForm']")).size() > 0) {
			return;
//			<form action="group.php" method="post" name="MainForm" accept-charset="utf-8">
//			<input type="hidden" value="" name="group">
		}
		openUrl(baseUrl);
	}

	void gotoHomePage() {
		//if (driver.findElement(By.cssSelector("h1#header")).getText().equals("Home page") { return; }
		//if (getCurrentUrl() != "http://localhost:8080/addressbookv4.1.4/")	{	}
		if (driver.findElements(By.xpath("//form[@name='MainForm']")).size() > 0) {
			return;
		}
		click(By.linkText("home page"));
	}

	public void clickExport() {
		openUrl(manager.getProperty("baseUrl") + "csv.php");		//manager.getProperty("baseUrl")
	}
}
